package com.zspace.lwq.boot.provider.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.google.common.collect.Lists;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.zspace.lwq.user.bean.UserAddress;
import com.zspace.lwq.user.service.UserService;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

@Service
@Component
public class UserServiceImpl implements UserService {

    //@HystrixCommand     // hystrix 代理
    @Override
    public List<UserAddress> getUserAddressList(String userId) {
        int random = new Random().nextInt(2) + 1;
        System.out.println("random: " + random);
        if (random > 1) {
            throw new RuntimeException("random exception");
        }
        UserAddress address1 = new UserAddress(1, "北京市", "1", "李老师", "010-12234", "Y");
        UserAddress address2 = new UserAddress(2, "兰州市", "1", "王老师", "020-22234", "N");
        return Lists.newArrayList(address1, address2);
    }

}
